/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ricm4.ar.nio.nioEngine;

import java.nio.channels.SocketChannel;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 * @author fx
 */
public class RecvMsgHandler implements I_RecvMsgHandler {

	private Map<SocketChannel, byte[]> messages = new ConcurrentHashMap<>();
	
	@Override
	public void receivedCB(byte[] data, SocketChannel socketChannel) {
		byte[] bytes = messages.get(socketChannel);
		if (bytes == null){
			bytes = new byte[0];
		}
		byte[] newBytes = new byte[bytes.length]; 
		System.arraycopy(bytes, 0, newBytes, 0, bytes.length); 
		System.arraycopy(data, 0, newBytes, bytes.length, data.length); 
		messages.put(socketChannel, newBytes); 
	}
}
